﻿@using PagedList
@model PagedList.IPagedList<ShenLanCMS.Models.Link>
@{
    ViewBag.Title = "友情链接管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
    function showStatus(obj) {
        if (obj == "1")
            document.write("审核通过");
        else
            document.write("审核中");
    }
</script>
<fieldset>
    <legend>友情链接管理 @Html.ActionLink("添加", "create")| @Html.ActionLink("待审核的友情链接", "approve")</legend>
    <br />
    <table>
        <tr>
            <th>
                站点名称
            </th>
            <th>
                Logo
            </th>
            <th>
                加入时间
            </th>
            <th>
                点击
            </th>
            <th>
                排序
            </th>
            <th>
                状态
            </th>
            <th>
                操作
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    <a href="@item.SiteUrl" target="_blank">@Html.DisplayFor(modelItem => item.SiteName)</a>
                </td>
                <td>
                    @{
                                                       if (string.IsNullOrEmpty(item.Logo))
                                                       {
                        @Html.Raw("暂无");
                                                       }
                                                       else
                                                       {
                        @Html.Raw("<img src='" + item.Logo + "' title='" + item.SiteName + "' width='88' height='31' />");
                                                       }
                    }
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.AddTime)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Click)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Sort)
                </td>
                <td>
                    <script>showStatus(@item.Status)</script>
                </td>
                <td>
                    @Html.ActionLink("编辑", "Edit", new { id = item.LinkID }) | <a href="javascript:delLink('@item.LinkID')">
                        删除</a>
                </td>
            </tr>
        }
    </table>
    <div style="width: auto; height: 30px; margin-top: 10px; text-align: center;">
        @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
        / @Model.PageCount
        &nbsp;
        @if (Model.HasPreviousPage)
        {
            @Html.ActionLink("首页", ViewData["actionName"].ToString(), new { page = 1, currentFilter = ViewBag.CurrentFilter })
            @Html.Raw("&nbsp;");
            @Html.ActionLink(" 上一页", ViewData["actionName"].ToString(), new { page = Model.PageNumber - 1, currentFilter = ViewBag.CurrentFilter })
        }
        else
        {
            @Html.Raw("首页&nbsp;&nbsp;上一页")
        }
        &nbsp;
        @if (Model.HasNextPage)
        {
            @Html.ActionLink("下一页 ", ViewData["actionName"].ToString(), new { page = Model.PageNumber + 1, currentFilter = ViewBag.CurrentFilter })
            @Html.Raw("&nbsp;");
            @Html.ActionLink(" 尾页", ViewData["actionName"].ToString(), new { page = Model.PageCount, currentFilter = ViewBag.CurrentFilter })
        }
        else
        {
            @Html.Raw("下一页&nbsp;&nbsp;尾页")
        }
    </div>
</fieldset>
<script type="text/javascript">
    function delLink(obj) {
        if (confirm("您确定要删除吗?")) {
            $.post("delete/" + obj, function (data) {
                alert(data);
                if (data == "删除成功")
                    window.location.reload();
            });
        }
    }
</script>
